#pragma once

#include <assert.h>

template <typename T>
class Queen
{
public:
	static const int Max_Data_Len = 50;
	Queen();
	~Queen();

	bool IsEmpty()
	{
		return _head == _tail;
	}

	bool DeleteHead(T *c = nullptr)
	{
		if (_head == _tail)
		{
			return false;
		}
		
		if (nullptr != c)
		{
			*c = _data[_head];
		}
		_head = (_head + 1) % Max_Data_Len;

		return true;
	}

	bool Entry(const T& c)
	{
		int next = (_tail + 1) % Max_Data_Len;
		if (next == _head)
		{
			return false;
		}
		_data[_tail] = c;
		_tail = next;
		return true;
	}

	T getHead()
	{
		assert(_head != _tail);
		return _data[_head];
	}

private:
	int _head, _tail;
	T _data[Max_Data_Len];
};

template <typename T>
Queen<T>::Queen() : _head(0), _tail(0)
{
}

template <typename T>
Queen<T>::~Queen()
{
}

